function checkyushen(id) {
    $.get(baseURL + "sys/tianan/info/" + id, function (r) {
        vm.tianan = r.tianan;
        var content = '<div id="test1" style="padding:10px 10px  0 10px">' +
            '<div class="form-group  " style="text-align: center;" > 案由分析</div>' +
            '<div class="form-group wenzi anyoufenxi" style="margin-top: 10px;border: 1px #999 solid;"></div>' +
            '<div class="form-group " style="text-align: center;" > 措施建议</div>' +
            '<div class="form-group wenzi  cuoshijianyi" style="margin-top: 10px;border: 1px #999 solid;"></div>' +
            '<div class="form-group wenzi renyuan" style=""></div>' +
            '<div class="form-group wenzi " style="margin-top: 10px;"> 标签：<input type="text" style="height: 35px; margin-right: 20px;" class="biaoqian"  placeholder="标签" ><select  class="leixing selectpicker form-control" title="请选择"></select></div></div>';
        layer.open({
            title: vm.tianan.title,
            shade: 0.5,
            type: 1,
            skin: 'layui-layer-molv',
            area: ['800px', '450px'],
            btn: ['预审'],
            content: content,
            success: function (layero, index) {

                //评分组件代码 +
                $(".anyoufenxi").html("<p>" + vm.tianan.anyoufenxi + "</p>");
                $(".cuoshijianyi").html("<p>" + vm.tianan.cuoshijianyi + "</p>");
                var dict = getDict('tiantype');
                var sel = "";
                for (var i = 0; i < dict.length; i++) {
                    sel += '<option value="' + dict[i].id + '">' + dict[i].value + '</option>'
                }
                $(".leixing").html(sel);
                $('.leixing').selectpicker({
                    width: '160px'
                });
                $('.leixing').selectpicker('refresh');
                $('.leixing').selectpicker('val',vm.tianan.types);
                $(".renyuan").html("<p>提案人："+vm.tianan.creatusername+"&nbsp;&nbsp;&nbsp;所属部门："+vm.tianan.deptIdName+"</p>")
            },
            //确认回调
            btn1: function () {
                vm.tianan.yushenstatus = 1;
                vm.tianan.types = $('.leixing').selectpicker('val');
                vm.tianan.lable= $('.biaoqian').val();
                var url = "sys/tianan/updateyushen";
                $.ajax({
                    type: "POST",
                    url: baseURL + url,
                    contentType: "application/json",
                    data: JSON.stringify(vm.tianan),
                    success: function (r) {
                        if (r.code === 0) {
                            layer.msg("提交成功", {icon: 1});
                            vm.reload();
                        } else {
                            layer.alert(r.msg);

                        }
                    }
                });
                layer.closeAll()
            },


        });


    });
}
function exports(){
    var xhr ;
    if(window.XMLHttpRequest){//code for IE7+,Firefox,Chrome,Opera,Safari
        xhr = new XMLHttpRequest();
    }else{//code for IE6,IE5
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var url = baseURL+'sys/tianan/exports';
    //设置响应类型为blob类型
    xhr.responseType = "blob";
    xhr.open("post", url, true);
    xhr.onload = function () {
        if (this.status == "200") {
            //获取响应文件流　　
            var blob = this.response;
            var reader = new FileReader();
            reader.readAsDataURL(blob);    // 转换为base64，可以直接放入a表情href
            reader.onload = function (e) {
                // 转换完成，创建一个a标签用于下载
                var a = document.createElement('a');
                a.download = '提案数据.xls';
                a.href = e.target.result;
                $("body").append(a);    // 修复firefox中无法触发click
                a.click();
                $(a).remove();
            }
        }
    }


    xhr.send();


 

}
function exportes(){
    var xhr ;
    if(window.XMLHttpRequest){//code for IE7+,Firefox,Chrome,Opera,Safari
        xhr = new XMLHttpRequest();
    }else{//code for IE6,IE5
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var url = baseURL+'sys/tianan/exports';
    //设置响应类型为blob类型
    xhr.responseType = "blob";
    xhr.open("post", url, true);
    xhr.onload = function () {
        if (this.status == "200") {
            //获取响应文件流　　
            var blob = this.response;
            var reader = new FileReader();
            reader.readAsDataURL(blob);    // 转换为base64，可以直接放入a表情href
            reader.onload = function (e) {
                // 转换完成，创建一个a标签用于下载
                var a = document.createElement('a');
                a.download = '提案数据.xls';
                a.href = e.target.result;
                $("body").append(a);    // 修复firefox中无法触发click
                a.click();
                $(a).remove();
            }
        }
    }


    xhr.send();




}
function init() {

    $("#jqGridtable").html("");
    $("#jqGridtable").html('<table id="jqGrid"></table><div id="jqGridPager"></div>');
    $("#jqGrid").jqGrid({
        url: baseURL + 'sys/tianan/listyushen?sea='+$("#sea").val()+'&yushenstatus='+$("#types").val(),
        datatype: "json",
        colModel: [
            {label: '提案名称', name: 'title', index: 'title', width: 80},

            {
                label: '提案类型',
                name: 'typesName',
                index: 'typesName',
                align: 'center',
                width: 40,},
            {label: '提案人', align: 'center', sortable: true, name: 'creatusername', index: 'dept_id', width: 40},
            {label: '办理部门', name: 'deptIdName', align: 'center', sortable: true, index: 'deptIdName', width: 40},
            {
                label: '标签',
                align: 'center',
                sortable: true,
                name: 'lable',
                index: 'lable',
                width: 40,
            },
            {
                label: '操作',
                name: 'id',
                align: 'center',
                index: 'id',
                width: 40,
                formatter: function (value, row, rowObject) {
                    var but = "";
                    but += ' <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="info(' + value + ')">详情</button>';
                    if (rowObject.yushenstatus == 0) {
                        but += '<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="checkyushen(' + value + ')">预审</button>';
                    }

                    return but;
                }
            }


        ],
        viewrecords: true,
        height: 360,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
}

$(function () {
init()


});

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        tiananShenyi: {},
        tianan: {}
    },
    methods: {
        query: function () {
            vm.reload();
        },
        add: function () {
            vm.showList = false;
            vm.title = "新增";
            vm.tiananShenyi = {};
        },
        update: function (event) {
            var id = getSelectedRow();
            if (id == null) {
                return;
            }
            vm.showList = false;
            vm.title = "修改";

            vm.getInfo(id)
        },
        saveOrUpdate: function (event) {
            $('#btnSaveOrUpdate').button('loading').delay(1000).queue(function () {
                var url = vm.tiananShenyi.id == null ? "sys/tiananshenyi/save" : "sys/tiananshenyi/update";
                $.ajax({
                    type: "POST",
                    url: baseURL + url,
                    contentType: "application/json",
                    data: JSON.stringify(vm.tiananShenyi),
                    success: function (r) {
                        if (r.code === 0) {
                            layer.msg("操作成功", {icon: 1});
                            vm.reload();
                            $('#btnSaveOrUpdate').button('reset');
                            $('#btnSaveOrUpdate').dequeue();
                        } else {
                            layer.alert(r.msg);
                            $('#btnSaveOrUpdate').button('reset');
                            $('#btnSaveOrUpdate').dequeue();
                        }
                    }
                });
            });
        },
        del: function (event) {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var lock = false;
            layer.confirm('确定要删除选中的记录？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                if (!lock) {
                    lock = true;
                    $.ajax({
                        type: "POST",
                        url: baseURL + "sys/tiananshenyi/delete",
                        contentType: "application/json",
                        data: JSON.stringify(ids),
                        success: function (r) {
                            if (r.code == 0) {
                                layer.msg("操作成功", {icon: 1});
                                $("#jqGrid").trigger("reloadGrid");
                            } else {
                                layer.alert(r.msg);
                            }
                        }
                    });
                }
            }, function () {
            });
        },
        getInfo: function (id) {
            $.get(baseURL + "sys/tiananshenyi/info/" + id, function (r) {
                vm.tiananShenyi = r.tiananShenyi;
            });
        },
        gettiananInfo: function (id) {

        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                page: page
            }).trigger("reloadGrid");
        }
    }
});